<%@page contentType="text/html;charset=utf-8" isELIgnored="false" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
    <title>发件箱</title>
    <link rel="icon" href="../favicon.ico" type="image/ico">
    <link href="${base}/css/bootstrap.min.css" rel="stylesheet">
    <link href="${base}/css/materialdesignicons.min.css" rel="stylesheet">
    <link href="${base}/css/style.min.css" rel="stylesheet">
    <link href="${base}/css/animate.css" rel="stylesheet">
    <style>

    </style>
</head>

<body>
<div class="topbar" style="background-color: deepskyblue;opacity: 0.5">
    <div class="topbar-left">
        <div class="lyear-aside-toggler">
        </div>
        <span class="navbar-page-title" style="margin-left: 80px"> <h3 style="color: black">发件箱</h3> </span>
    </div>
    <ul class="topbar-right">
        <li class="dropdown dropdown-profile">
            <img style="display: inline-block" class="img-avatar img-avatar-48 m-r-10" src="${base}/upload/${theUser.headpic}" />
            <span style="color: crimson">${theUser.name}</span>
            <a style="display: inline-block;color: black" href="${base}/toHome">回到首页</a>
        </li>
    </ul>
</div>
<div class="container-fluid">
    <div class="row">
        <div class="col-lg-12" style="background-image: url(${base}/img/444.jpg);background-size: 120%">
            <div class="card" style="width: 1200px;height: 800px;margin-left:auto;margin-right:auto;opacity: 0.9">
                <div>
                    <form method="get" action="${base}/information/selectAllInfsByMy">
                        <div class="input-group">
                            <input type="text" class="form-control" value="" name="likes" placeholder="根据标题搜索"
                                   style="width: 230px;margin-top: 30px;margin-left: 25px; ">
                            <button class="btn btn-cyan btn-w-md" type="submit" style="margin-top: 30px;width: 100px"
                            >搜索
                            </button>
                            <input type="hidden" name="search_field" id="search-field" value="title">
                        </div>
                    </form>
                </div>

                <div class="card-toolbar clearfix">
                    <div class="toolbar-btn-action">
                        <a class="btn btn-primary m-r-5" href="${base}/friends/selectAllfs"></i>我的好友</a>
                        <a class="btn btn-primary m-r-5" href="${base}/information/selectAllInfsByMy"> 发件箱</a>
                        <a class="btn btn-danger" onclick="allDelete()">全部删除</a>
                    </div>
                </div>

                <div class="card-body">

                    <div class="table-responsive">
                        <form action="" method="post" id="form4">
                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <th>
                                        <label class="lyear-checkbox checkbox-primary">
                                            <input type="checkbox" id="check-all"><span></span>
                                        </label>
                                    </th>
                                    <td>编号</td>
                                    <th>标题</th>
                                    <th>时间</th>
                                    <th>状态</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <c:forEach var="i" items="${p.list}">
                                    <tr>
                                        <td>
                                            <label class="lyear-checkbox checkbox-primary">
                                                <input type="checkbox" name="cks" value="${i.id}"><span></span>
                                            </label>
                                        </td>
                                        <td>${i.id}</td>
                                        <td>${i.title}</td>
                                        <td><fmt:formatDate value="${i.createtime}"
                                                            pattern="yy-MM-dd HH:mm:ss"></fmt:formatDate></td>
                                        <td>已发</td>

                                        <div id="s${i.id}" hidden style=" z-index: 100;position: fixed; padding: 20px;width: 600px;
                                            height: 400px;background-color: white;left: 50%;top: 50%; transform: translate(-50%, -50%);
                                            border-radius: 4px;box-shadow: 2px 2px 4px rgba(2, 2, 2, .5);">
                                            <h3>信息来自于：${i.user1.name}</h3>
                                            <p align="right">
                                                <button onclick="(function() {
                                                  var aa = document.getElementById('s${i.id}');
                                                  aa.hidden = true;
                                                })()">x</button>
                                            </p>
                                            <input type="hidden" value="${f.id}" name="accept">
                                            <p>标题：${i.title}</p>
                                            <p>内容：${i.content}</p>
                                            <p><a  onclick="(function() {
                                                    lightyear.loading('show');
                                                    setTimeout(function () {
                                                    lightyear.loading('hide');
                                                    lightyear.notify('已删除~', 'success', 1000);
                                                    }, 0)
                                                    setTimeout(function() {
                                                    $('#form4').attr('action','${base}/information/updateSend?id=${i.id}');
                                                    $('#form4').submit();
                                                    },500)
                                                    })()">删除</a>
                                               </p>
                                        </div>
                                        <td>
                                            <div class="btn-group">
                                                <div class="btn-group btn-group-round">
                                                    <a class="btn btn-default"  onclick="yidu(s${i.id},${i.id})">查  看</a>

                                                    <a class="btn btn-default"
                                                       onclick="(function() {
                                                               lightyear.loading('show');
                                                               setTimeout(function () {
                                                               lightyear.loading('hide');
                                                               lightyear.notify('已删除~', 'success', 1000);
                                                               }, 0)
                                                               setTimeout(function() {
                                                               $('#form4').attr('action','${base}/information/updateSend?id=${i.id}');
                                                               $('#form4').submit();
                                                               },500)
                                                               })()"
                                                    >删除</a>
                                                </div>
                                            </div>
                                        </td>
                                    </tr>
                                </c:forEach>
                                </tbody>
                            </table>
                        </form>
                    </div>
                    <ul class="pagination">
                        <li><a href="${base}/information/selectAllInfsByMy?pageNum=1&likes=${likes}">«</a></li>
                        <li><a href="${base}/information/selectAllInfsByMy?pageNum=${p.prePage}&likes=${likes}">上一页</a></li>
                        <c:forEach var="i" items="${p.navigatepageNums}">
                            <li <c:if test="${i eq p.pageNum}">class="active"</c:if>><a
                                    href="${base}/information/selectAllInfsByMy?pageNum=${i}&likes=${likes}">${i}</a></li>
                        </c:forEach>
                        <li><a href="${base}/information/selectAllInfsByMy?pageNum=${p.nextPage}&likes=${likes}">下一页</a>
                        </li>
                        <li><a href="${base}/information/selectAllInfsByMy?pageNum=${p.pages}&likes=${likes}">»</a></li>
                    </ul>

                </div>
            </div>
        </div>

    </div>

</div>

<script type="text/javascript" src="${base}/js/jquery.min.js"></script>
<script type="text/javascript" src="${base}/js/bootstrap.min.js"></script>
<script type="text/javascript" src="${base}/js/perfect-scrollbar.min.js"></script>
<script type="text/javascript" src="${base}/js/main.min.js"></script>

<script src="${base}/js/bootstrap-notify.min.js"></script>
<script type="text/javascript" src="${base}/js/lightyear.js"></script>
<script type="text/javascript" src="${base}/js/main.min.js"></script>
<script type="text/javascript">
    $(function () {
        $('.search-bar .dropdown-menu a').click(function () {
            var field = $(this).data('field') || '';
            $('#search-field').val(field);
            $('#search-btn').html($(this).text() + ' <span class="caret"></span>');
        });
    });
    document.onclick = function (event) {
        if (!box.contains(event.target) && mybtn != event.target) {
            box.hidden = true;
        }
    }
    function allUpdate() {
        $("#form4").attr("action","${base}/information/updateAllAcceptState");
        $("#form4").submit();
    }
    function allDelete() {
        $("#form4").attr("action","${base}/information/deleteAllInfs?type=1");
        $("#form4").submit();
    }
   function yidu(aaa,id) {
       aaa.hidden = false;
       $.post('${base}/information/updateYidu?id='+id);
   }

</script>
</body>
</html>